using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Drawing;
using funktionsplotter.contracts;

namespace funktionsplotter.app
{
    public class Plotten : IPlotten
    {
        private readonly ICompilieren compile;
        private readonly IX_Werte_generieren xcalc;
        private readonly IY_Werte_berechnen ycalc;

        public Plotten(ICompilieren compile, IX_Werte_generieren xcalc, IY_Werte_berechnen ycalc)
        {
            this.compile = compile;
            this.xcalc = xcalc;
            this.ycalc = ycalc;
        }

        public IEnumerable<Point> Process(Tuple<string, double, double, int> daten)
        {
            Trace.TraceInformation("Plotten: {0}", daten.Item1);
            var f = this.compile.Process(daten.Item1);
            var xwerte = this.xcalc.Process(new Tuple<double, double, int>(daten.Item2, daten.Item3, daten.Item4));
            return this.ycalc.Process(new Tuple<Func<double, double>, IEnumerable<double>>(f, xwerte));
        }
    }
}